import com.sun.javaws.IconUtil;
public class Student {
    public String name;
    public int age;

    //构造方法 -- 无返回值，名称和类名相同
    public Student(){
        //this()可以调用本类中其他的构造方法,条件：必须放在构造方法里，且只能放在第一行
        //this("王五",99);
        System.out.println("不带参数的构造方法");
    }

    public Student(String name,int age){
        //不能循环调用
        //this();
        System.out.println("带两个参数的构造方法");
        this.name = name;
        this.age = age;
    }

    public void setStudent(String name,int age){
        System.out.println("带两个参数的构造方法");
        this.name = name;
        this.age = age;
    }

     public void print(){
        System.out.println(this.name+" => "+this.age);
     }

     public static void main1(String[] args){
        Student student = new Student();
        student.setStudent("bit",12);
        student.print();
     }

    public static void main(String[] args) {
        //如果只实现了带两个参数的构造方法但是没有实现无参数构造方法，则编译器不会生成无参数构造方法
        Student student1 = new Student();
        Student student2 = new Student("张三",18);
    }
}
